#ifndef H_LIST
#define H_LIST

#include "debug.h"

class Listable {
};

class ListNode { //Double linked list
   public:
      ListNode*	  prev;
      Listable*		part;
      ListNode* next;

      ListNode	( ListNode* _prev , Listable & _part,	//#D
			   ListNode* _next) {			
	 prev = _prev; next = _next; part = &_part;
      }
};

class List {
   private:
      ListNode* list;
      ListNode* iterator;
      ListNode* iteratorB;

   public:
      List () { //#D
	 list = 0;
	 iterator = 0;
	 iteratorB = 0;
      }

      void add ( Listable * );
      void reset () {	   //#D
	 iterator = list;
	 if ( iterator != 0 ) {
	    iteratorB = list->next;
	 } else
	    iteratorB = 0;
      }

      virtual Listable * listIter ();

      ListNode* getHead() {	 //#D
	 return list; 
      }

      Listable* advanceHead ( ListNode** );
      
      Listable** doubleIter ( Listable** ); // iters two iterators
};
#endif
